
package com.insigma.business.qrcode.common.converter;

import com.google.common.collect.Lists;

import com.insigma.business.qrcode.common.dao.CommonAdminAreaDO;
import com.insigma.business.qrcode.common.dto.CommonAdminAreaBSearcher;
import com.insigma.business.qrcode.common.dto.CommonAdminAreaDTO;
import com.insigma.business.qrcode.common.dto.CommonAdminAreaSearchRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class CommonAdminAreaProviderConverter extends AbstractConverter<CommonAdminAreaDTO, CommonAdminAreaDO> {

    private final static CommonAdminAreaProviderConverter commonAdminAreaConverter = new CommonAdminAreaProviderConverter();

    private CommonAdminAreaProviderConverter(){}

    
    public static CommonAdminAreaBSearcher convertRequestSO2Searcher(final CommonAdminAreaSearchRequest request){
        final CommonAdminAreaBSearcher commonAdminAreaBSearcher = new CommonAdminAreaBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,commonAdminAreaBSearcher);
        return commonAdminAreaBSearcher;
    }

    


    

    
    public static List<CommonAdminAreaDTO> convertResponseDOList2DTOList(final List<CommonAdminAreaDO> commonAdminAreaDOList){
        return commonAdminAreaConverter.convertGenericResponseDOList2DTOList(commonAdminAreaDOList);
    }

    
    public static CommonAdminAreaDTO convertResponseDO2DTO(final CommonAdminAreaDO commonAdminAreaDO){
        return commonAdminAreaConverter.convertGenericResponseDO2DTO(commonAdminAreaDO);
    }

    public static List<CommonAdminAreaDTO> convertListDO2Dto(List<CommonAdminAreaDO> result) {
        List<CommonAdminAreaDTO> list = Lists.newArrayList();
        for (CommonAdminAreaDO commonAdminAreaDO : result) {
            list.add(commonAdminAreaConverter.doConvertResponseDO2DTO(commonAdminAreaDO));
        }
        return list;
    }

    
    @Override
    protected CommonAdminAreaDTO doConvertResponseDO2DTO(CommonAdminAreaDO commonAdminAreaDO) {
        final CommonAdminAreaDTO commonAdminAreaDTO = new CommonAdminAreaDTO();
        try {
            BeanUtils.copyProperties(commonAdminAreaDO, commonAdminAreaDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return commonAdminAreaDTO;
    }


}
